home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1998 April / MACPOWER-1998-04.ISO.7z / MACPOWER-1998-04.ISO / Shareware Paradise / Tabler.091.sit / Tabler 0.9.1 / source code / Tabler.FKEY.c < prev    next >
C/C++ Source or Header  |  1996-11-02  |  2KB  |  114 lines

  1. /*
  2.  *--------------------------------------------------------------
  3.  * Tabler.FKEY.c
  4.  *--------------------------------------------------------------
  5.  *    FKEY verion of Tabler
  6.  *--------------------------------------------------------------
  7.  */
  8.  
  9. /* System Include Headers */
  10. #include <Types.h>
  11. #include <Memory.h>
  12. #include <Scrap.h>
  13. #include <Errors.h>
  14.  
  15. #ifdef __powerc
  16.     #ifdef SYMANTEC_C
  17.         #include <stdlib.h>
  18.     #endif
  19. #else
  20.     #ifdef __MWERKS__
  21.         #include <A4Stuff.h>
  22.     #endif
  23.     #ifdef THINK_C
  24.         #include <SetUpA4.h>
  25.     #endif
  26. #endif
  27.  
  28. /* Project Include Header */
  29. #include "Tabler.h"
  30.  
  31. /* Implementation */
  32. /*
  33.  *--------------------------------------------------------------
  34.  * main
  35.  *--------------------------------------------------------------
  36.  *    main is main, cannot be whatever else.
  37.  *    This includes, however, an essential glue to be able to
  38.  *    access the global area.
  39.  *--------------------------------------------------------------
  40.  */
  41. void main(void)
  42. {
  43. #ifdef __powerc
  44.     #ifdef SYMANTEC_C
  45.     __rsrcinit();
  46.     #endif
  47. #else
  48.     #ifdef __MWERKS__
  49.         long oldA4 = SetCurrentA4();
  50.     #endif
  51.     #ifdef THINK_C
  52.         RememberA0();
  53.         SetUpA4();
  54.     #endif
  55. #endif
  56.  
  57.     OSErr    result = ConvertScrap();
  58.     if (result != noErr) {
  59.         SysBeep(20);
  60.     }
  61.  
  62. #ifdef __powerc
  63.     #ifdef SYMANTEC_C
  64.     __rsrcterm();
  65.     #endif
  66. #else
  67.     #ifdef __MWERKS__
  68.         SetA4(oldA4);
  69.     #endif
  70.     #ifdef THINK_C
  71.         RestoreA4();
  72.     #endif
  73. #endif
  74. }
  75. /*
  76.  *--------------------------------------------------------------
  77.  * SoundMyClick
  78.  *--------------------------------------------------------------
  79.  *    FKEY version of playing a click sound.
  80.  *    Since the FKEY does not stay in the resource chain,
  81.  *    we have to obtain the sound resource by finding our
  82.  *    FKEY file itself and opening it.
  83.  *--------------------------------------------------------------
  84.  */
  85. void SoundMyClick(void)
  86. {
  87.     FSSpec    fkeySpec;
  88.     short    aVRefNum;
  89.     long    aDirID;
  90.     OSErr    result;
  91.  
  92.     result = FindFolder(kOnSystemDisk, kFontsFolderType, kDontCreateFolder,
  93.                 &aVRefNum, &aDirID);
  94.     if (result == noErr) {
  95.         result = FSMakeFSSpec(aVRefNum, aDirID, "¥pTabler.FKEY", &fkeySpec);
  96.         if (result == noErr) {
  97.  
  98.             short    saveFRef = CurResFile();
  99.             short    fkeyFRef;
  100.  
  101.             SetResLoad(false);
  102.             fkeyFRef = FSpOpenResFile(&fkeySpec, fsRdPerm);
  103.             result = ResError();
  104.             SetResLoad(true);
  105.             if (result == noErr) {
  106.                 UseResFile(fkeyFRef);
  107.                 PlayAClick();
  108.                 CloseResFile(fkeyFRef);
  109.             }
  110.             UseResFile(saveFRef);
  111.         }
  112.     }
  113. }
  114. /* end of Tabler.FKEY.c */